<?php
function http_request( $url, $post = '', $timeout = 5 ){ 
	if( empty( $url ) ){
	 return ;
	}
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	if( $post != '' && !empty( $post ) ){
	 curl_setopt($ch, CURLOPT_POST, 1);
	 curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',' Connection: Keep-Alive',
	    'Keep-Alive: 300','Accept-Encoding:gzip','Accept-Chreset:utf-8'));
	}
	curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
	$res = curl_exec($ch);
	$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE); 
	curl_close($ch);
	if($httpCode==201){
		$result = array('status'=>$httpCode,'errcode'=>0,'mesage'=>'发送成功','data'=>$res);
		$result=json_encode($result,true);
	}
	if ($httpCode==0) {
		$result = array('status'=>$httpCode,'errcode'=>404,'mesage'=>'服务器未响应');
		$result=json_encode($result,true);
	}
	if($httpCode == 500){
		if(empty($result)){
		$result = array('status'=>$httpCode,'errcode'=>500,'mesage'=>'请求服务器被你玩挂了，赶紧跑路');
		$result=json_encode($result,true);
		}
		
	}
	return $result;
}
function is_json($string){
	json_decode($string);
	return (json_last_error() == JSON_ERROR_NONE);
}
function check_type_float($data){
	if(is_array($data)){
		if(!empty($data['Address'])){
			$data['Address'] = floatval($data['Address']);
		}
		
		if(!empty($data['UpdateTime'])){
			$data['UpdateTime'] = floatval($data['UpdateTime']);
		}
		if(!empty($data['VehicleNum'])){
			$data['VehicleNum'] = floatval($data['VehicleNum']);
		}
		if(!empty($data['DriverNum'])){
			$data['DriverNum'] = floatval($data['DriverNum']);
		}
		if(!empty($data['CountDate'])){
			$data['CountDate'] = floatval($data['CountDate']);
		}
		if(!empty($data['Flag'])){
		// 	switch ($data['Flag']) {
		// 		case '新增':
		// 			$data['Flag'] =1;
		// 			break;
				
		// 		case '更新':
		// 			$data['Flag'] =2;
		// 			break;
		// 		case '删除':
		// 			$data['Flag'] =3;
		// 			break;
		// 	}
			$data['Flag'] = floatval($data['Flag']);
		}
		if(!empty($data['State'])){
			// switch ($data['State']) {
			// 	case '有效':
			// 		$data['State'] =0;
			// 		break;
				
			// 	case '失效':
			// 		$data['State'] =1;
			// 		break;
			// }
			$data['State'] = floatval($data['State']);
		}
		// if(!empty($data['PayState'])){
		// 	switch ($data['PayState']) {
		// 		case '未结算':
		// 			$data['PayState'] ="0";
		// 			break;
				
		// 		case '已结算':
		// 			$data['PayState'] ="1";
		// 			break;
		// 		case '未知':
		// 			$data['PayState'] ="2";
		// 			break;
		// 	}
		// 	//$data['State'] = floatval($data['State']);
		// }
		// if(!empty($data['BizStatus'])){
		// 	switch ($data['BizStatus']) {
		// 		case '载客':
		// 			$data['BizStatus'] =1;
		// 			break;
		// 		case '接单':
		// 			$data['BizStatus'] =2;
		// 			break;
		// 		case '空驶':
		// 			$data['BizStatus'] =3;
		// 			break;
		// 		case '停运':
		// 			$data['BizStatus'] =4;
		// 			break;
		// 	}
		// 	//$data['State'] = floatval($data['State']);
		// }
		//  if(!empty($data['InvoiceStatus'])){
		// 	switch ($data['InvoiceStatus']) {
		// 		case '未开票':
		// 			$data['InvoiceStatus'] ="0";
		// 			break;
		// 		case '已开票':
		// 			$data['InvoiceStatus'] ="1";
		// 			break;
		// 		case '未知':
		// 			$data['InvoiceStatus'] ="2";
		// 			break;
		// 	}
		// 	//$data['State'] = floatval($data['State']);
		// }
		//  if(!empty($data['CancelTypeCode'])){
		// 	switch ($data['CancelTypeCode']) {
		// 		case '乘客提前取消':
		// 			$data['CancelTypeCode'] ="0";
		// 			break;
		// 		case '驾驶员提前撤销':
		// 			$data['CancelTypeCode'] ="1";
		// 			break;
		// 		case '平台公司撤销':
		// 			$data['CancelTypeCode'] ="2";
		// 			break;
		// 		case '乘客违约撤销':
		// 			$data['CancelTypeCode'] ="3";
		// 			break;
		// 		case '驾驶员违约撤销':
		// 			$data['CancelTypeCode'] ="4";
		// 			break;
		// 	}
		// 	//$data['State'] = floatval($data['State']);
		// }
		// if(!empty($data['Operator'])){
		// 	switch ($data['Operator']) {
		// 		case '乘客':
		// 			$data['Operator'] ="0";
		// 			break;
		// 		case '驾驶员':
		// 			$data['Operator'] ="1";
		// 			break;
		// 		case '平台公司':
		// 			$data['Operator'] ="2";
		// 			break;
		// 	}
		// 	//$data['State'] = floatval($data['State']);
		// }
		// if(!empty($data['MapType'])){
		// 	switch ($data['MapType']) {
		// 		case '百度地图':
		// 			$data['MapType'] =1;
		// 			break;
		// 		case '高德地图':
		// 			$data['MapType'] =2;
		// 			break;
		// 		case '其他':
		// 			$data['MapType'] =3;
		// 			break;
		// 	}
		// 	
		// }
		if(!empty($data['CreateDate'])){
			$data['CreateDate'] = floatval($data['CreateDate']);
		}
		if(!empty($data['StartDate'])){
			$data['StartDate'] = floatval($data['StartDate']);
		}
		if(!empty($data['StopDate'])){
			$data['StopDate'] = floatval($data['StopDate']);
		}
		
		if(!empty($data['LogoutTime'])){
			$data['LogoutTime'] = floatval($data['LogoutTime']);
		}
		if(!empty($data['CertifyDate'])){
			$data['CertifyDate'] = floatval($data['CertifyDate']);
		}
		if(!empty($data['FareValidOn'])){
			$data['FareValidOn'] = floatval($data['FareValidOn']);
		}
		if(!empty($data['FareValidOff'])){
			$data['FareValidOff'] = floatval($data['FareValidOff']);
		}
		if(!empty($data['Seats'])){
			$data['Seats'] = floatval($data['Seats']);
		}
		if(!empty($data['CertifyDateA'])){
			$data['CertifyDateA'] = floatval($data['CertifyDateA']);
		}
		if(!empty($data['TransDateStart'])){
			$data['TransDateStart'] = floatval($data['TransDateStart']);
		}
		if(!empty($data['TransDateStop'])){
			$data['TransDateStop'] = floatval($data['TransDateStop']);
		}
		if(!empty($data['CertifyDateB'])){
			$data['CertifyDateB'] = floatval($data['CertifyDateB']);
		}
		if(!empty($data['NextFixDate'])){
			$data['NextFixDate'] = floatval($data['NextFixDate']);
		}
		if(!empty($data['GPSInstallDate'])){
			$data['GPSInstallDate'] = floatval($data['GPSInstallDate']);
		}
		if(!empty($data['RegisterDate'])){
			$data['RegisterDate'] = floatval($data['RegisterDate']);
		}
		if(!empty($data['CommercialType'])){
			$data['CommercialType'] = floatval($data['CommercialType']);
		}
		if(!empty($data['InsurEff'])){
			$data['InsurEff'] = floatval($data['InsurEff']);
		}
		if(!empty($data['InsurCount'])){
			$data['InsurCount'] = floatval($data['InsurCount']);
		}
		if(!empty($data['InsurExp'])){
			$data['InsurExp'] = floatval($data['InsurExp']);
		}
		if(!empty($data['TotalMile'])){
			$data['TotalMile'] = floatval($data['TotalMile']);
		}
		if(!empty($data['DriverBirthday'])){
			$data['DriverBirthday'] = floatval($data['DriverBirthday']);
		}
		if(!empty($data['GetDriverLicenseDate'])){
			$data['GetDriverLicenseDate'] = floatval($data['GetDriverLicenseDate']);
		}
		if(!empty($data['DriverLicenseOn'])){
			$data['DriverLicenseOn'] = floatval($data['DriverLicenseOn']);
		}
		if(!empty($data['DriverLicenseOff'])){
			$data['DriverLicenseOff'] = floatval($data['DriverLicenseOff']);
		}
		if(!empty($data['TaxiDriver'])){
			$data['TaxiDriver'] = floatval($data['TaxiDriver']);
		}
		if(!empty($data['NetworkCarIssueDate'])){
			$data['NetworkCarIssueDate'] = floatval($data['NetworkCarIssueDate']);
		}
		if(!empty($data['GetNetworkCarProofDate'])){
			$data['GetNetworkCarProofDate'] = floatval($data['GetNetworkCarProofDate']);
		}
		if(!empty($data['NetworkCarProofOn'])){
			$data['NetworkCarProofOn'] = floatval($data['NetworkCarProofOn']);
		}
		if(!empty($data['NetworkCarProofOff'])){
			$data['NetworkCarProofOff'] = floatval($data['NetworkCarProofOff']);
		}
		if(!empty($data['FullTimeDriver'])){
			$data['FullTimeDriver'] = floatval($data['FullTimeDriver']);
		}
		if(!empty($data['InDriverBlacklist'])){
			$data['InDriverBlacklist'] = floatval($data['InDriverBlacklist']);
		}
		if(!empty($data['ContractOn'])){
			$data['ContractOn'] = floatval($data['ContractOn']);
		}
		if(!empty($data['ContractOff'])){
			$data['ContractOff'] = floatval($data['ContractOff']);
		}
		if(!empty($data['CourseDate'])){
			$data['CourseDate'] = floatval($data['CourseDate']);
		}
		if(!empty($data['Duration'])){
			$data['Duration'] = floatval($data['Duration']);
		}
		if(!empty($data['NetType'])){
			$data['NetType'] = floatval($data['NetType']);
		}
		if(!empty($data['MapeType'])){
			$data['MapeType'] = floatval($data['MapeType']);
		}
		if(!empty($data['Cycle'])){
			$data['Cycle'] = floatval($data['Cycle']);
		}
		if(!empty($data['OrderCount'])){
			$data['OrderCount'] = floatval($data['OrderCount']);
		}
		if(!empty($data['TrafficViolationCount'])){
			$data['TrafficViolationCount'] = floatval($data['TrafficViolationCount']);
		}
		if(!empty($data['ComplainedCount'])){
			$data['ComplainedCount'] = floatval($data['ComplainedCount']);
		}
		if(!empty($data['DepartTime'])){
			$data['DepartTime'] = floatval($data['DepartTime']);
		}
		if(!empty($data['OrderTime'])){
			$data['OrderTime'] = floatval($data['OrderTime']);
		}
		if(!empty($data['DepLongitude'])){
			$data['DepLongitude'] = floatval($data['DepLongitude']*1000000);
		}
		if(!empty($data['DepLatitude'])){
			$data['DepLatitude'] = floatval($data['DepLatitude']*1000000);
		}
		if(!empty($data['DestLongitude'])){
			$data['DestLongitude'] = floatval($data['DestLongitude']*1000000);
		}
		if(!empty($data['DestLatitude'])){
			$data['DestLatitude'] = floatval($data['DestLatitude']*1000000);
		}
		if(!empty($data['Longitude'])){
			$data['Longitude'] = floatval($data['Longitude']*1000000);
		}
		if(!empty($data['Latitude'])){
			$data['Latitude'] = floatval($data['Latitude']*1000000);
		}
		if(!empty($data['Encrypt'])){
			$data['Encrypt'] = floatval($data['Encrypt']);
		}
		if(!empty($data['DistributeTime'])){
			$data['DistributeTime'] = floatval($data['DistributeTime']);
		}
		if(!empty($data['CancelTime'])){
			$data['CancelTime'] = floatval($data['CancelTime']);
		}
		if(!empty($data['LoginTime'])){
			$data['LoginTime'] = floatval($data['LoginTime']);
		}
		if(!empty($data['DestTime'])){
			$data['DestTime'] = floatval($data['DestTime']);
		}
		if(!empty($data['DriveMile'])){
			$data['DriveMile'] = floatval($data['DriveMile']);
		}
		if(!empty($data['DriveTime'])){
			$data['DriveTime'] = floatval($data['DriveTime']);
		}
		if(!empty($data['OnArea'])){
			$data['OnArea'] = floatval($data['OnArea']);
		}
		if(!empty($data['BookDepTime'])){
			$data['BookDepTime'] = floatval($data['BookDepTime']);
		}
		if(!empty($data['WaitTime'])){
			$data['WaitTime'] = floatval($data['WaitTime']);
		}
		if(!empty($data['DepTime'])){
			$data['DepTime'] = floatval($data['DepTime']);
		}
		if(!empty($data['DestTime'])){
			$data['DestTime'] = floatval($data['DestTime']);
		}
		if(!empty($data['WaitMile'])){
			$data['WaitMile'] = floatval($data['WaitMile']);
		}
		if(!empty($data['FactPrice'])){
			$data['FactPrice'] = floatval($data['FactPrice']);
		}
		if(!empty($data['Price'])){
			$data['Price'] = floatval($data['Price']);
		}
		if(!empty($data['CashPrice'])){
			$data['CashPrice'] = floatval($data['CashPrice']);
		}
		if(!empty($data['LinePrice'])){
			$data['LinePrice'] = floatval($data['LinePrice']);
		}
		if(!empty($data['PosPrice'])){
			$data['PosPrice'] = floatval($data['PosPrice']);
		}
		if(!empty($data['BenfitPrice'])){
			$data['BenfitPrice'] = floatval($data['BenfitPrice']);
		}
		if(!empty($data['BookTip'])){
			$data['BookTip'] = floatval($data['BookTip']);
		}
		if(!empty($data['PassengerTip'])){
			$data['PassengerTip'] = floatval($data['PassengerTip']);
		}
		if(!empty($data['PeakUpPrice'])){
			$data['PeakUpPrice'] = floatval($data['PeakUpPrice']);
		}
		if(!empty($data['NightUpPrice'])){
			$data['NightUpPrice'] = floatval($data['NightUpPrice']);
		}
		if(!empty($data['FarUpPrice'])){
			$data['FarUpPrice'] = floatval($data['FarUpPrice']);
		}
		if(!empty($data['OtherUpPrice'])){
			$data['OtherUpPrice'] = floatval($data['OtherUpPrice']);
		}
		// if(!empty($data['PayState'])){
		// 	$data['PayState'] = floatval($data['PayState']);
		// }
		if(!empty($data['PayTime'])){
			$data['PayTime'] = floatval($data['PayTime']);
		}
		if(!empty($data['OrderMatchTime'])){
			$data['OrderMatchTime'] = floatval($data['OrderMatchTime']);
		}
		if(!empty($data['DriverRegionCode'])){
			$data['DriverRegionCode'] = floatval($data['DriverRegionCode']);
		}
		if(!empty($data['PositionTime'])){
			$data['PositionTime'] = floatval($data['PositionTime']);
		}
		if(!empty($data['Direction'])){
			$data['Direction'] = floatval($data['Direction']);
		}
		if(!empty($data['Elevation'])){
			$data['Elevation'] = floatval($data['Elevation']);
		}
		if(!empty($data['Speed'])){
			$data['Speed'] = floatval($data['Speed']);
		}
		if(!empty($data['BizStatus'])){
			$data['BizStatus'] = floatval($data['BizStatus']);
		}
		// if(!empty($data['VehicleNo'])){
		// 	$data['VehicleNo'] = floatval($data['VehicleNo']);
		// }
		if(!empty($data['VehicleRegionCode'])){
			$data['VehicleRegionCode'] = floatval($data['VehicleRegionCode']);
		}
		if(!empty($data['Mileage'])){
			$data['Mileage'] = floatval($data['Mileage']);
		}
		if(!empty($data['WarnStatus'])){
			$data['WarnStatus'] = floatval($data['WarnStatus']);
		}
		if(!empty($data['VehStatus'])){
			$data['VehStatus'] = floatval($data['VehStatus']);
		}
		if(!empty($data['EvaluateTime'])){
			$data['EvaluateTime'] = floatval($data['EvaluateTime']);
		}
		// if(!empty($data['ServiceScore'])){
		// 	$data['ServiceScore'] = floatval($data['ServiceScore']);
		// }
		if(!empty($data['DriverScore'])){
			$data['DriverScore'] = floatval($data['DriverScore']);
		}
		if(!empty($data['BookDepartTime'])){
			$data['BookDepartTime'] = floatval($data['BookDepartTime']);
		}
		if(!empty($data['ComplaintTime'])){
			$data['ComplaintTime'] = floatval($data['ComplaintTime']);
		}
		if(!empty($data['PunishTime'])){
			$data['PunishTime'] = floatval($data['PunishTime']);
		}
		if(!empty($data['Level'])){
			$data['Level'] = floatval($data['Level']);
		}
		if(!empty($data['TestDate'])){
			$data['TestDate'] = floatval($data['TestDate']);
		}
		if(!empty($data['RouteMile'])){
			$data['RouteMile'] = floatval($data['RouteMile']);
		}
		if(!empty($data['RouteCreateTime'])){
			$data['RouteCreateTime'] = floatval($data['RouteCreateTime']);
		}
		if(!empty($data['OrderEnsureTime'])){
			$data['OrderEnsureTime'] = floatval($data['OrderEnsureTime']);
		}
		if(!empty($data['PassengerNum'])){
			$data['PassengerNum'] = floatval($data['PassengerNum']);
		}
		if(!empty($data['ShareFuelFee'])){
			$data['ShareFuelFee'] = floatval($data['ShareFuelFee']);
		}
		if(!empty($data['ShareHightwayToll'])){
			$data['ShareHightwayToll'] = floatval($data['ShareHightwayToll']);
		}
		if(!empty($data['ShareOther'])){
			$data['ShareOther'] = floatval($data['ShareOther']);
		}
		if(!empty($data['InDriverBlacklist'])){
			$data['InDriverBlacklist'] = floatval($data['InDriverBlacklist']);
		}
	return $data;
	}else{
		exit(json_encode(array('errCode'=>4006,'message'=>'数据类型错误'),true)) ;
	}
}

?>


  